<h1>Contacts</h1>

<p>
  <%= link_to 'New contact', new_contact_path %>
</p>

<table class="contacts internal">
  <tr>
    <th>#</th>
    <th><%= link_to 'Email', :action => :index, :sort => :email %></th>
    <th><%= link_to 'Active', :action => :index, :sort => :active %></th>
    <th><%= link_to 'Created', :action => :index, :sort => :created_at %></th>
    <th><%= link_to 'Updated', :action => :index, :sort => :updated_at %></th>
  </tr>

<% @contacts.each_with_index do |contact, index| %>
  <tr class="<%= cycle 'odd', 'even'%>">
    <td><%= index + 1 %></td>
    <td><%=h contact.email %></td>
    <td><%=h contact.active %></td>
    <td><%=time_ago_in_words contact.created_at %> ago</td>
    <td><%=time_ago_in_words contact.updated_at %> ago</td>
    <td><%= link_to 'Edit', edit_contact_path(contact) %></td>
    <td><%= link_to 'Delete', contact, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>
